﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ThoiTrang.Entities;
using System.Collections.Generic;
using ThoiTrang.Business;

public partial class UserControls_FeaturedArticles : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadFeaturedArticles();
    }

    protected void LoadFeaturedArticles()
    {
        try
        {
            List<a_Article> arts = a_ArticleService.GetFeaturedArticles();
            for (int i = 0; i < arts.Count; i++)
            {
                ShowFeaturedArticle(arts[i]);
            }

        }
        catch (Exception ex)
        {
        }
    }

    protected void ShowFeaturedArticle(a_Article art)
    {
        switch (art.FeaturedType)
        {
            case 1:
                lnkImg1.HRef = ResolveUrl(String.Format("~/detail.aspx?{0}={1}&p=1&{2}={3}", FOConstants.QSP_AID, art.ID, FOConstants.QSP_CKID, SessionManager.GetCookie()));
                lnkImg1.Title = art.UTitle;
                img1.Src = TTHelper.GetFeaturedImagePath(art);
                break;
            case 2:
                lnkImg2.HRef = ResolveUrl(String.Format("~/detail.aspx?{0}={1}&p=1&{2}={3}", FOConstants.QSP_AID, art.ID, FOConstants.QSP_CKID, SessionManager.GetCookie()));
                lnkImg2.Title = art.UTitle;
                img2.Src = TTHelper.GetFeaturedImagePath(art);
                break;
            case 3:
                lnkImg3.HRef = ResolveUrl(String.Format("~/detail.aspx?{0}={1}&p=1&{2}={3}", FOConstants.QSP_AID, art.ID, FOConstants.QSP_CKID, SessionManager.GetCookie()));
                lnkImg3.Title = art.UTitle;
                img3.Src = TTHelper.GetFeaturedImagePath(art);
                break;
            case 4:
                lnkImg4.HRef = ResolveUrl(String.Format("~/detail.aspx?{0}={1}&p=1&{2}={3}", FOConstants.QSP_AID, art.ID, FOConstants.QSP_CKID, SessionManager.GetCookie()));
                lnkImg4.Title = art.UTitle;
                img4.Src = TTHelper.GetFeaturedImagePath(art);
                break;
            case 5:
                lnkImg5.HRef = ResolveUrl(String.Format("~/detail.aspx?{0}={1}&p=1&{2}={3}", FOConstants.QSP_AID, art.ID, FOConstants.QSP_CKID, SessionManager.GetCookie()));
                lnkImg5.Title = art.UTitle;
                img5.Src = TTHelper.GetFeaturedImagePath(art);
                break;
        }
    }
}
